package c2.cross.business.championrace.handler;

import c2.cross.business.championrace.ChampionRaceModule;
import cate.game.pvp.championrace.timer.ChampionRaceTimerTask;
import cate.game.pvp.championrace.ChampionRaceSpecUtils;


public class ChampionRaceReadySettingHandler extends AbstractChampionRaceSettingHandler{
    public ChampionRaceReadySettingHandler(ChampionRaceModule parent) {
        super(parent);
    }

    @Override
    public boolean runSettingFunction(ChampionRaceTimerTask.Setting setting) {
        switch (setting.getEventType()) {
            case TRIAL:
                return runTrialWith(setting);
            case KO:
                return runKoWith(setting);
            case FINAL:
                return runFinalWith(setting);
            default:
                return true;
        }
    }

    @Override
    public boolean isMatch(ChampionRaceTimerTask.Setting setting) {
        return ChampionRaceSpecUtils.isMatchReadySimulator(setting);
    }

    @Override
    public void run() {

    }

    private boolean runTrialWith(ChampionRaceTimerTask.Setting setting) {
        parent.changeSpec(setting, ChampionRaceSpecUtils.getTrialFlag(setting));
        return true;
    }

    private boolean runFinalWith(ChampionRaceTimerTask.Setting setting) {
        parent.changeSpec(setting, ChampionRaceSpecUtils.getFinalFlag(setting));
        return true;
    }

    private boolean runKoWith(ChampionRaceTimerTask.Setting setting) {
        parent.changeSpec(setting, ChampionRaceSpecUtils.getKoFlag(setting));
        return true;
    }
}
